package javaassist;

import javassist.*;

/**
 * javassit字节码增强
 */
public class Test {

    public static void main(String[] args) throws Exception {
        ClassPool cp = ClassPool.getDefault();
        CtClass cc = cp.get("javaassist.TestJava");
        CtMethod m = cc.getDeclaredMethod("process");
        m.insertBefore("{ System.out.println(\"start\"); }");
        m.insertAfter("{ System.out.println(\"end\"); }");
        Class c = cc.toClass();
//        cc.writeFile("C:");
        TestJava h = (TestJava)c.newInstance();
        h.process();
    }

}
